import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";

import Admin from "../views/Admin.vue";
import AdminArticleNew from "../views/admin/article/ArticleNew.vue";
import Login from "../views/Login.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
  },
  {
    path: "/login",
    name: "Login",
    component: Login,
  },
  {
    path: "/admin",
    name: "Admin",
    component: Admin,
    children: [
      {
        path: "article",
        name: "AdminArticle",
        component: () => import("../views/admin/article/Article.vue"),
      },
      {
        path: "article/new",
        name: "AdminArticleNew",
        component: AdminArticleNew,
      },
      {
        path: "article/update",
        name: "AdminArticleUpdate",
        component: () => import("../views/admin/article/ArticleUpdate.vue"),
      },
      {
        path: "article/:article_id",
        name: "AdminArticleDetail",
        component: () => import("../views/admin/article/ArticleDetail.vue"),
        props: true,
      },
    ],
  },
  {
    path: "/about",
    name: "About",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/About.vue"),
  },
  {
    path: "/helloworld",
    name: "HellowWorld",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../components/HelloWorld.vue"),
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
